package com.yjhb.android.sbz.mvp.hall;

import com.yjhb.android.sbz.entity.TaskInfo;
import com.yjhb.android.sbz.http.HttpObserver;
import com.yjhb.android.sbz.http.HttpTool;
import com.yjhb.android.sbz.mvp.ConventionPresenter;

import java.util.List;

/**
 * 创建者 zx
 * 创建时间 2021/1/19 9:17
 */
public class HallPresenter extends ConventionPresenter<HallTaskView> {
    private final String TAG = "HallPresenter";

    public HallPresenter(HallTaskView hallTaskView) {
        super(hallTaskView);
    }

    @Override
    protected void onDestroy() {

    }





    @Deprecated
    public void randomHomePageList(){
//        HttpTool.request(model.randomHomePageList(), new HttpObserver<List<TaskInfo>>() {
//            @Override
//            public void onResult(List<TaskInfo> data) {
//                if (view!=null){
//                    view.onRandomList(data);
//                }
//            }
//
//            @Override
//            public void onError(int code, String msg) {
//                if (view != null) {
//                    view.onFailure(code, msg);
//                }
//            }
//        });
    }

    /**
     *
     * @param sortBy
     * @param type
     * @param categoryId
     * @param size
     * @param current
     */
    @Deprecated
    public void loadHallList(int sortBy ,Integer type, Integer categoryId, int size, final int current) {
        HttpTool.request(model.hallTaskList(sortBy,type,categoryId,null,size,current), new HttpObserver<List<TaskInfo>>() {
            @Override
            public void onResult(List<TaskInfo> data) {
                if (view != null) {
                    if (current == 1)
                        view.onListData(data, true);
                    else
                        view.onListData(data, false);
                }
            }

            @Override
            public void onError(int code, String msg) {
                if (view != null) {
                    view.onFailure(code, msg);
                }
            }
        });
    }


    /**
     * 新版本悬赏大厅列表接口
     * @param sortBy
     * @param categoryId
     * @param size
     * @param current
     */
    public void loadHallListV2(int sortBy,Integer categoryId,int size, final int current){
        HttpTool.request(model.hallList(sortBy,categoryId,size,current), new HttpObserver<List<TaskInfo>>() {
            @Override
            public void onResult(List<TaskInfo> data) {
                if (view != null) {
                    if (current == 1)
                        view.onListData(data, true);
                    else
                        view.onListData(data, false);
                }
            }

            @Override
            public void onError(int code, String msg) {
                if (view != null) {
                    view.onFailure(code, msg);
                }
            }
        });
    }
}
